package com.siteseat.crudeq.kernel;

import com.siteseat.crudeq.kernel.exception.DeployException;
import com.siteseat.crudeq.kernel.impl.QueueManagerImpl;

/**
 *
 */
public class Hello {

  /**
   * @param args
   * @throws DeployException
   */
  public static void main( String[] args ) throws Exception {
    final QueueManagerImpl qm = new QueueManagerImpl();
    qm.init();

    QueueProfile profile = new QueueProfile();
    profile.setChunkFolderPath( "d:\\chunk_temp" );
    profile.setId( 1 );
    profile.setName( "HelloCrudeQ" );

    qm.deploy( null, profile );

    Queue q = qm.find( profile.getId() );
    for( int i = 0; i < 64 * 1024; i++ ) {
      Message msg = q.prepare( 1260 );
      q.commit( msg );
    }

    Runtime.getRuntime().addShutdownHook( new Thread() {
      @Override
      public void run() {
        try {
          qm.destroy();
        } catch( Exception e ) {
          e.printStackTrace();
        }
      }
    } );
  }

}
